 //轮播图片的JS

var i = 1;
 function autoChangeImage(i){  
    console.log("Being here");              //自动改变图片
    setTimeout("changeImage(i++); ", 3300);
    
    setTimeout("autoChangeImage(i = (i%5))", 3300);
} 
function changeImage(idNum){
    document.getElementById("radio" + idNum).checked = "checked";
    switch(idNum){
        // document.getElementById("imgIndex").innerHTML = "<img src='images/pictureSlider/"+idNum+ ".jpg'/>";
        case 0:

            document.getElementById("imgIndex").innerHTML = "<a href=''><img src='images/pictureSlider/0.png'/></a>";
            document.getElementById("picture-slider-title").innerHTML="<p>2015新生留学生入学典礼</p>";
            break;
        case 1:
            document.getElementById("imgIndex").innerHTML = "<a href=''><img src='images/pictureSlider/2.jpg'/></a>";
            document.getElementById("picture-slider-title").innerHTML="<p>2015新生留学生入学典礼</p>";
            break;
        case 2:
            document.getElementById("imgIndex").innerHTML = "<a href=''><img src='images/pictureSlider/0.png'/></a>";
            break;
        case 3:
            document.getElementById("imgIndex").innerHTML = "<a href=''><img src='images/pictureSlider/1.jpg'/></a>";
            document.getElementById("picture-slider-title").innerHTML="<p>2015新生留学生入学典礼</p>";
            break;
        case 4:
            document.getElementById("imgIndex").innerHTML = "<a href=''><img src='images/pictureSlider/2.jpg'/></a>";
            document.getElementById("picture-slider-title").innerHTML="<p>2015新生留学生入学典礼</p>";
            break;
    }
}
autoChangeImage(0);
   

    var today     = new Date();
    var thisDate  = today.getDate();
    var thisMonth = today.getMonth();
    var thisYear  = today.getFullYear();
    var thisDay   = today.getDay();  //星期
    var currentYear     = thisYear;
    var currentMonth    = thisMonth;
    var Month_InChinese = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct',
    'Nov','Dec'];
    var events          =[
        {
            date:'20151130',
            event:"在楠苑多功能厅有一场学术报告会"
        },
        {
            date:'20151203',
            event:"在图书馆有一场学术报告会"
        },
        {
            date:'20151205',
            event:"在图书馆有一场学术报告会"
        }
    ];

    //设置表头的年月
    function setDate(){
        var month =1+currentMonth;
        document.getElementsByClassName('calendar-title-date')[0].innerHTML = currentYear + "年" + month + "月";
    }

    function Init(){
        var firstDayOfTheMonth = new Date(currentYear,currentMonth,1);
        var strHTML = "<tr><th>Su</th><th>Mo</th><th>Th</th><th>Wu</th><th>Th</th><th>Fr</th><th>Sa</th></tr>";
        //加入上月空白节点
        for(var i=0;i<firstDayOfTheMonth.getDay();i++){
            strHTML+="<td></td>";
        }

        //得到当月的最大天数
        var tempDate = new Date(currentYear,currentMonth+1,0);
        var numOfDays =  tempDate.getDate();

        //增加要显示的天数
        for(var j = 1;j<=numOfDays;j++){
            tempDate = new Date(currentYear,currentMonth,j);
            if(tempDate.getDate()==thisDate&&tempDate.getMonth()==thisMonth&&tempDate.getFullYear()==thisYear)
                strHTML +="<td class='today'>" + j + "</td>";
            else strHTML += "<td>" + j + "</td>";
            if(tempDate.getDay()===6) strHTML +="</tr><tr>";
        }

        strHTML +="</tr>";
        document.getElementById("calendar").innerHTML = strHTML;
    }

    //为有活动的日子增加样式
    function importantDay() {
        var month,day,year;
        for (var i = 0; i < events.length; i++) {
            //目标--年月日
            year  = parseInt(events[i].date.substring(0, 4));
            month = parseInt(events[i].date.substring(4, 6));
            day   = parseInt(events[i].date.substring(6,8));
            if (year == currentYear && month == currentMonth + 1) {
                var tds = document.getElementsByTagName('td');
                var len = tds.length;
                for (var j = 0; j < len; j++)
                    if (parseInt(tds[j].innerHTML) == day) {
                        tds[j].innerHTML ="<a href='#'>" +day +"</a>";
                        tds[j].style.cssText= 'color:#333; border:1px solid gray;';
                    }
            }

        }
    }

    function lastMonth(){
        if(currentMonth==0){
            --currentYear;
            currentMonth = 11;
          }else currentMonth--;
        setDate();
        Init();
        importantDay();
    }

    function nextMonth(){
        if(currentMonth==11){
            ++currentYear;
            currentMonth = 0;
        }else ++currentMonth;
        setDate();
        Init();
        importantDay();
    }

    function sortEvent(){
        var len = events.length;
        for (var i = 0; i <len-1; i++) {
            for(var j=i+1;j<len;j++){
                if(parseInt(events[i].date)>parseInt(events[j].date))
                    swap(events[i],events[j]);
            }
        }
        function swap(a,b){
            var temp={date:"",event:""};
            temp.date = a.date;
            temp.event = a.event;
            a.date = b.date;
            a.event = b.event;
            b.date = temp.date;
            b.content = temp.content;
        }

    }

    function setEvent(){

        var IntToday = parseInt(""+thisYear + ((1+thisMonth)>9?(1+thisMonth):("0"+(1+thisMonth))) +
         (thisDate>9?thisDate:("0"+thisDate)));
       
        var len = events.length;
        for (var i = 0; i <len; i++) {
            if(parseInt(events[i].date)>=IntToday){
                document.getElementsByClassName("recentEvent-Day")[0].innerHTML = events[i].date.substring(6,8);
                document.getElementsByClassName("recentEvent-Month")[0].innerHTML =
                        Month_InChinese[parseInt(events[i].date.substring(4,6))-1];
                document.getElementsByClassName("recentEvent-content")[0].innerHTML =
                        '<p><a href="">' + events[i].event + ' >>></a></p>';
                return;
            }
        }
    }

    Init();
    setDate();
    importantDay();

    //初始化时，先将events按时间排序
    sortEvent();
    //显示下一个事件
    setEvent();

